'    Copyright 2008 Jan Molnar <jan.molnar@abds.de>
'
'    This file is part of JCQ.

'    JCQ is free software: you can redistribute it and/or modify
'    it under the terms of the GNU General Public License as published by
'    the Free Software Foundation, either version 2 of the License, or
'    (at your option) any later version.

'    JCQ is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU General Public License for more details.

'    You should have received a copy of the GNU General Public License
'    along with JCQ. If not, see <http://www.gnu.org/licenses/>.

Public Class ExceptionWindowViewModel
    Implements System.ComponentModel.INotifyPropertyChanged

    Public Sub New()
        AddHandler JCsTools.Core.Kernel.Exceptions.ExceptionPublished, AddressOf OnException
    End Sub

    Private Sub OnException(ByVal sender As Object, ByVal e As Core.Interfaces.ExceptionEventArgs)
        Message += String.Format("{0}: {1}", Date.Now.ToLongTimeString, e.ExceptionInfo.Exception.ToString & System.Environment.NewLine & System.Environment.NewLine)
    End Sub

    Private _Message As String
    Public Property Message() As String
        Get
            Return _Message
        End Get
        Set(ByVal value As String)
            _Message = value

            OnPropertyChanged("Message")
        End Set
    End Property

    Private Sub OnPropertyChanged(ByVal propertyName As String)
        RaiseEvent PropertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(propertyName))
    End Sub

    Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
End Class
